package inesv.activeMQ.queue_topic_demo;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQTextMessage;

import javax.jms.*;

public class TopicProducer {
    public static void main(String[] args) throws JMSException {
        ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
        Connection connection = activeMQConnectionFactory.createConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Topic topic = session.createTopic("test-topic");
        MessageProducer messageProducer = session.createProducer(topic);
        TextMessage textMessage = new ActiveMQTextMessage();
        textMessage.setText("欢迎使用topic模式的MQ");
        messageProducer.send(textMessage);
        messageProducer.close();
        session.close();

    }
}
